home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
answrbok
/
6_14.lha
/
6_14
/
tsta.c
< prev
next >
Wrap
Text File
|
1993-08-08
|
947b
|
29 lines
* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
* The C++ Answer Book */
* Tony Hansen */
* All rights reserved. */
include <stream.h>
include "6_14a.c"
stream &operator<<(ostream &out, complex j)
return out << "(" << j.re << ", " << j.im << ")"; }
nline complex complex::operator+(complex j) { complex x(re+j.re, im+j.im); return x; }
nline complex complex::operator-(complex j) { complex x(re-j.re, im-j.im); return x; }
nline complex complex::operator-() { complex x(-re, -im); return x; }
nline complex complex::operator*(complex j) { complex x(re*j.re, im*j.im); return x; }
ain()
complex i = 0.0, j = 1.0;
cout << "i= " << i << ", j=" << j << "\n";
i = j + 3.0;
cout << "i= " << i << ", j=" << j << "\n";
i = j - 3.0;
cout << "i= " << i << ", j=" << j << "\n";
i = -j;
cout << "i= " << i << ", j=" << j << "\n";
i = i * j;
cout << "i= " << i << ", j=" << j << "\n";
return 0;